package nowcoder.offer;

import java.util.HashSet;

/**
 * 数组中重复的数字
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-08-28 19:35
 */
public class Duplicate {

    public boolean solution(int numbers[],int length,int[] duplication){

        if (numbers == null || length == 0)
            return false;
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < length; i++) {
            if (set.contains(numbers[i])){
                duplication[0] = numbers[i];
                return true;
            }
            set.add(numbers[i]);
        }

        return false;
    }
}
